package com.anda.jsu.yangsp.core.persistence;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import com.anda.jsu.yangsp.core.view.util.PageModel;

/**
 * 
 * @author xiaolu
 * @since 2012-08-22
 * @param <T>
 */
public interface IBasicDao<T> {


	/**
	 * 添加实体
	 * 
	 * @param t
	 */
	public T save(T t);

	public T saveOrUpdate(T t);

	public T update(T t);

	public void saveOrUpdateAll(Collection<T> entities);

	/**
	 * 删除实体
	 * 
	 * @param t
	 * @return
	 */
	public void delete(T t);

	public void deleteAll(Collection<T> entities);

	/**
	 * 根据Id查找实体
	 * 
	 * @param entityId
	 * @return
	 */
	public T selectById(Class<T> clazz, Serializable entityId);

	/**
	 * 返回小批量数据所有的实体
	 * 
	 * @return @
	 */
	public List<T> selectSmallTs(final String entityName);

	/**
	 * 返回大批量数据
	 * 
	 * @return @
	 */
	public List<T> selectMaxTs(final String entityName);

	/**
	 * 分页查询
	 * 
	 * @param pageNo
	 * @param pageSzie
	 * @return @
	 */
	public PageModel<T> selectByPage(final String entityName, int pageNo, int pageSize);

	/**
	 * 返回总的记录数
	 * 
	 * @return @
	 */
	public Long selectTotalCount(final String entityName);

	public List<Object[]> findPageBySQL(final String sql, final Boolean isPage, final int start, final int limit);

	public int countBySQL(final String sql);

	public Long selectCountBySelectSQL(final String selectSQL);

	public List<T> list(final PageModel<T> view);
	
}
